package com.lxj.service.impl;

import com.lxj.domain.GroupMember;
import com.lxj.mapper.GroupMemberMapper;
import com.lxj.service.GroupMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class GroupMemberServiceImpl implements GroupMemberService {
    @Autowired
    private GroupMemberMapper groupMemberMapper;
    @Override
    public List<GroupMember> findMemberByGroupId(Integer id) {
        return groupMemberMapper.findMemberByGroupId(id);
    }

    @Override
    public List<GroupMember> findContainUser(Integer id) {
        return groupMemberMapper.findContainUser(id);
    }

    @Override
    @Transactional
    public int cancelMember(GroupMember groupMember) {
        groupLeader(groupMember);
        return groupMemberMapper.cancelMember(groupMember);
    }

    @Override
    public int addMember(GroupMember groupMember) {
        return groupMemberMapper.addMember(groupMember);
    }

    @Override
    public List<GroupMember> selectAll(GroupMember groupMember) {
        return groupMemberMapper.selectAll(groupMember);
    }

    @Override
    public int getCount() {
        return groupMemberMapper.getCount();
    }

    @Override
    public List<GroupMember> findByGroupId(Integer id) {
        return groupMemberMapper.findByGroupId(id);
    }

    @Override
    public void groupLeader(GroupMember groupMember) {
        groupMemberMapper.groupLeader(groupMember);
    }

    @Override
    public GroupMember findById(Integer id) {
        return groupMemberMapper.findById(id);
    }
}
